<?php
  /**
     * 递归查询
     */
    function cate_index($pid)
    {
        // var_dump($pid);
        $moder = M('category');
        $data = [];
        $cate = $moder->where(array('pid' => $pid))->select();
        foreach ($cate as $key => $value) {
            $value['sub'] = cate_index($value['id']);
            $data[] = $value;
        }
        
        return $data;
    }

    function category_ppd()
    {   
        $moder = M('category');
        $list  = $moder->field("*,concat(path,',',id) as bpath")->order('bpath')->select();
        foreach ($list as $key => $value) {
            $tmp = explode(',',$value['path']);
            $len = count($tmp) - 1;
            $list[$key]['name'] = str_repeat('&nbsp;'.'|----',$len).$value['name'];
        }
        
        return $list;
    }